package com.mtsmda.bookjava7.chapter11.generics;

import java.util.List;

public class GenericMethod {
	
	public <T> T getT(List<T> list){
		if(list != null && !list.isEmpty()){
			return list.get(0);
		}
		return null;
	}
	
	public <T extends Number> double avg(List<T > list){
		double avg = 0.0;
		double sum = 0;
		int count = 0;
		for(T t : list){
			sum += t.doubleValue();
			count++;
		}
		
		avg = sum / count;
		
		return avg;
	}
	
}